﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL.Translator
{
    /// <summary>
    /// Define Authority Translator
    /// </summary>
    public class AuthorityTranslator
    {
        /// <summary>
        /// To Translate AuthorityDataEntity to AuthorityBusinessEntity
        /// </summary>
        /// <param name="authorityDE"></param>
        /// <returns></returns>
        public static BLL.Authority TranslateEntityToBusiness(DAL.Authority authorityDE)
        {
            BLL.Authority authorityBE = new BLL.Authority();
            authorityBE.AuthorityId = authorityDE.AuthorityId;
            authorityBE.AuthorityName = authorityDE.AuthorityName;
            if (authorityDE.AuthorityLevel == null)
            {
                authorityBE.Level = null;
            }
            else
            {
                authorityBE.Level = Translator.AuthorityLevelTranslator.TranslateEntityToBusiness(authorityDE.AuthorityLevel);
            }
            return authorityBE;
        }

        /// <summary>
        /// To Translate AuthorityBusinessEntity to AuthorityDataEntity
        /// </summary>
        /// <param name="authorityBE"></param>
        /// <returns></returns>
        public static DAL.Authority TranslateBusinessToEntity(BLL.Authority authorityBE)
        {
            DAL.Authority authorityDE = new DAL.Authority();
            authorityDE.AuthorityId = authorityBE.AuthorityId;
            authorityDE.AuthorityName = authorityBE.AuthorityName;
            if (authorityBE.Level == null)
            {
                authorityDE.AuthorityLevel = null;
            }
            else
            {
                authorityDE.LevelId = authorityBE.Level.LevelId;
            }
            return authorityDE;
        }
    }

}
